<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
  <title>Document</title>
  <style>

  </style>
</head>

<body>

</body>
<script>
  //响应状态码是 2xx-----表示成功
  //响应状态码是3xx 4xx  5xx  ----表示失败
  const xhr = new XMLHttpRequest()

  xhr.addEventListener('load', function () {
    //通过xhr.status 获取响应状态码
    // console.log(xhr.status);
    if (xhr.status >= 200 && xhr.status < 300) {
      console.log('成功', JSON.parse(xhr.response));
    } else if (xhr.status >= 300) {
      console.log('失败', JOSN.parse(xhr.response));
    }
  })

  xhr.open('POST', '')


  xhr.setRequestHeader('', '')
  xhr.send()
</script>

</html>